//
//  ClassifyModel.swift
//  XiaoJingMallSwift
//
//  Created by beisheng03 on 2017/8/3.
//  Copyright © 2017年 beisheng. All rights reserved.
//

import UIKit

class ClassifyModel: NSObject {
    var gc_id = "-999"
    var gc_name = "-999"
    var child = [OneGroupModel]()


    init(dic : [String : AnyObject]) {
        super.init()
        
        setValuesForKeys(dic)
        
    }
    
    
    override func  setValue(_ value: Any?, forKey key: String) {
        
        if key == "child" {
            
            if let temp = value as? [[String : AnyObject]]{
                
                for dic in temp {
                    
                    let temp = OneGroupModel(dic:dic )
                    
                    if temp.grandson.count > 0 {
                        
                        child.append(temp)

                    }
                    
                }
                
                
            }
            
            
        } else {
            
            
            super.setValue(value, forKey: key)
        }
        
    }
    
    override func setValue(_ value: Any?, forUndefinedKey key: String) {
        
        
    }
    
    
    //在swift中想要打印对象要以下重写属性
    override var description: String{
        let keys = ["gc_id","gc_name","child"]
        let dic = dictionaryWithValues(forKeys: keys)
        return "\(dic)"
    }




}
